package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Dicgchannel;
import com.aaa.ssm.entity.Startegy;
import com.aaa.ssm.service.CommonFileHandlerService;
import com.aaa.ssm.service.StartegyService;

import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/car")
public class StartegyController extends BaseController{
    @Resource
    private StartegyService startegyService;
    @Resource
    private CommonFileHandlerService commonFileHandlerService;
    @RequestMapping("queryPage")
    public Result queryPage(@RequestBody Page<Startegy> page){
        return success(startegyService.queryPage(page));
    }

    /**
     * 文件上传对象  必须使用@RequestParam绑定上传对象,不可以少，少了上传不了
     * MultipartFile
     * @param file1
     * @return
     */
    @PostMapping("uploadFile")
    public Result uploadFile(@RequestParam MultipartFile file1){
        //调用封装的服务接口
        return success(commonFileHandlerService.uploadFile(file1,"Start/pic/"));
    }

    /**
     * 测试 没用
     * @param page
     * @return
     */
    @PostMapping("queryById")
    public Result queryById(@RequestBody Page<Startegy> page){
        return success(startegyService.queryById(page));
    }

    /**
     * 使景区咨询动态
     * @param page
     * @return
     */
    @PostMapping("queryByIdA")
    public Result queryByIdA(@RequestBody Page<Dicgchannel> page){
        return success(startegyService.queryByIdA(page));
    }
    @PostMapping("add")
    public Result add(@RequestBody Startegy startegy){
        return success(startegyService.add(startegy));
    }
    @PostMapping("update")
    public Result update(@RequestBody Startegy startegy){
        return success(startegyService.update(startegy));
    }
    @PostMapping("delete/{id}")
    public Result delete(@PathVariable("id") Integer id){
        return success(startegyService.delete(id));
    }
}
